import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNext()){
            //读取数据，创建迷宫数组
            int row = scanner.nextInt();
            int col = scanner.nextInt();
            int[][] mg = new int[row][col];
            for(int i=0;i<row;i++){
                for(int j=0;j<col;j++){
                    mg[i][j]= scanner.nextInt();
                }
            }
            //迷宫寻路
            StringBuffer sBuffer = new StringBuffer();
            findPath(mg,0,0,sBuffer);
            String[] split = sBuffer.toString().split(" ");
            for (int i = 0; i < split.length; i++) {
                System.out.println(split[split.length-1-i]);
            }
        }
    }

    private static boolean findPath(int[][] mg,int n,int m,StringBuffer sBuffer){
        int row = mg.length;
        int col = mg[0].length;
        if(row==(n+1)&&col==(m+1)){
            sBuffer.append("("+n+","+m+")").append(" ");
            //如果走到最右下角的坐标，则认为找到出口了
            return true;
        }
        if(mg[n][m]==0){
            // 2 标识已经走过了，下次不再走
            mg[n][m]=2;
            if(n+1<row){
                if(findPath(mg,n+1,m,sBuffer)){
                    sBuffer.append("("+n+","+m+")").append(" ");
                    return true;
                }
            }
            if(m+1<col){
                if(findPath(mg,n,m+1,sBuffer)){
                    sBuffer.append("("+n+","+m+")").append(" ");
                    return true;
                }
            }
            if(-1<n-1){
                if(findPath(mg,n-1,m,sBuffer)){
                    sBuffer.append("("+n+","+m+")").append(" ");
                    return true;
                }
            }
            if(-1<m-1){
                if(findPath(mg,n,m-1,sBuffer)){
                    sBuffer.append("("+n+","+m+")").append(" ");
                    return true;
                }
            }
            return false;
        }else{
            return false;
        }
    }
}